type GetReturnType<T> = T extends (...args:never[]) => infer R ? R : never

// //type Num1 = number
// type Num1 = GetReturnType<() => number>
// let num:Num1 = 111

// //type Str1 = string
// type Str1 = GetReturnType<(x:string) => string>
// let str:Str1 = ''

// //type Bools = boolean[]
// type Bools = GetReturnType<(a:boolean,b:boolean) => boolean[]>
// let bools:Bools = [true,false]

// //type Never = never
// type Never = GetReturnType<string>

// let nev:Never = 'error' as never

function stringOrNum(x: string): number
function stringOrNum(x: number): string
function stringOrNum(x: string | number): string | number
function stringOrNum(x:string | number): string | number{
  return Math.random() > 0.5 ? 'hello' : 23
}

//type T1 = string | number
type T1 = ReturnType<typeof stringOrNum>
/* const t1:T1 = true */